<template>
	<view class="container">
		<view class="menu flex-box flex-center">
			<view :class="'menuitem ' + (menu == 0 ? 'active' : '')" data-menuindex="0" @tap="choosemenu">楼市资讯</view>
			<view :class="'menuitem ' + (menu == 1 ? 'active' : '')" data-menuindex="1" @tap="choosemenu" v-if="onOff">买房问问</view>
			<!-- <view :class="'menuitem ' + (menu == 2 ? 'active' : '')" data-menuindex="2" @tap="choosemenu">楼盘动态</view> -->
		</view>
		

		<view class="part1 pt140" v-if='menu==0'>
			<swiper class="swiper">
				<swiper-item v-for="(item, index) in advertData">
					<image
						@tap.stop.prevent="jumpAdvertTo"
						:data-param="item"
						:data-jump_type="item.jump_type"
						:data-jump_param="item.jump_param"
						:src="item.image_text"
						:lazy-load="true"
						mode="aspectFill"
					></image>
				</swiper-item>
			</swiper>

			<view class="points">
				<view :class="'point ' + (sort == 1 ? 'active' : '')" @tap="changearticleType" data-sort="1">最新</view>
				<view :class="'point ' + (sort == 2 ? 'active' : '')" @tap="changearticleType" data-sort="2">最热</view>
				<view
					:class="'point ' + (article_category_id == item.id ? 'active' : '')"
					@tap="changearticleType"
					:data-id="item.id"
					v-for="(item, index) in articleType"
				   
				>
					{{ item.name }}
				</view>
			</view>

			<view class="informationlist">
				<template v-if="articleList.total > 0">
					<template v-for="(item, index) in articleList.data">
						<navigator :url="'/pages/article/info_detail/info_detail?id=' + item.id" class="infoitem" hover-class="none">
							<view class="flex-box">
								<view class="flex-grow-1">
									<view class="multi-line title">{{ item.name }}</view>
									<view class="single-line detail">{{ item.description }}</view>
								</view>
								<view class="infopic">
									<!-- <u--image :showLoading="true" :lazy-load="true" :src="item.image_text" radius="10rpx" width="240rpx" height="190rpx" mode="aspectFill"></u--image> -->
									<u--image :showLoading="true" :lazy-load="true" :src="item.image_text" radius="10rpx" width="100%" height="100%" mode="aspectFill"></u--image>
								</view>
							</view>
							<view class="flex-box flex-between avatar-share">
								<view class="flex-box flex-grow-1">
									<image :lazy-load="true" :src="item.author_avatar_text" class="avatar" mode="aspectFill"></image>
									<view class="fs24 col89 pr30">{{ item.author }}</view>
									<view class="fs24 col89">{{ item.createtime_text }}</view>
								</view>
								<button class="flex-box share" @tap.stop.prevent="share" :data-index="index">
									<image src="/static/icon/icon_share-b.png" class="icon_share-b"></image>
									<view class="fs24">分享</view>
								</button>
							</view>
						</navigator>
					</template>
					<u-loadmore v-if="articleList.total > 9" :status="loadStatus0" fontSize="24" line loading-text="努力加载中" loadmore-text="轻轻上拉"  nomore-text="没有更多了" />
				</template>
				<template v-else>
					<u-empty
					        mode="data"
							text="暂无数据"
							textSize="24"
					        icon="/static/images/none-data.png"
					>
					</u-empty>
				</template>
			</view>
		</view>

		<view class="part2 pt140" v-if='menu==1'>
			 <view class="bgf" style="padding-top: 13rpx">
				<image src="/static/icon/icon_ask.png" class="icon_ask" mode="aspectFill"></image>
				<view class="fs32 tc pb20">买房，从问问开始</view>
				<view class="fs24 tc col89">佳和房产承诺：所有问答均来自真实用户和咨询师购房交流过程中</view>
			</view>
			<view class="flex-box search" v-if="is_ask">
				<view class="search-box flex-box">
					<image src="/static/icon/icon_search.png" class="icon_search"></image>
					<input @confirm="doSearch" confirm-type="search" placeholder="搜你想知道的问题、答案" placeholder-class="colf" class="colf flex-grow-1" />
				</view>
				<view class="flex-grow-1 cancel" @tap="changeQuestionSearch">取消</view>
			</view>
			<view class="flex-box btns" v-if="!is_ask">
				<button class="flex-box flex-center askbtn" @tap="changeQuestionSearch">
					<image src="/static/icon/icon_ask1.png"></image>
					<view class="fs28 col89">问题搜索</view>
				</button>
				<navigator url="/pages/article/want_ask/want_ask" hover-class="none" class="flex-box flex-center askbtn">
					<image src="/static/icon/icon_ask2.png"></image>
					<view class="fs28 col89">我要问问</view>
				</navigator>
				<!-- #ifdef MP -->
				<button open-type="share" class="flex-box flex-center askbtn">
					<image src="/static/icon/icon_ask3.png"></image>
					<view class="fs28 col89">分享问问</view>
				</button>
				<!-- #endif -->
				<!-- #ifdef APP-PLUS -->
				<button @tap="sharemp" class="flex-box flex-center askbtn">
					<image src="/static/icon/icon_ask3.png"></image>
					<view class="fs28 col89">分享问问</view>
				</button>
				<!-- #endif -->
				<!-- #ifdef H5 -->
				<button @tap="copyUrl" class="flex-box flex-center askbtn">
					<image src="/static/icon/icon_ask3.png"></image>
					<view class="fs28 col89">分享问问</view>
				</button>
				<!-- #endif -->
			</view>
			<view class="points">
				<view :class="'point ' + (is_has_image == 1 ? 'active' : '')" @tap="changequestionType" data-has="1">全部</view>
				<view :class="'point ' + (is_has_image == 2 ? 'active' : '')" @tap="changequestionType" data-has="2">有图</view>
				<view :class="'point ' + (tags_id == item.id ? 'active' : '')" :data-id="item.id" @tap="changequestionType" v-for="(item, index) in questionType">
					{{ item.name }}
				</view>
			</view>
			<view class="queslist">
				<block v-if="questionList.total > 0">
					<block v-for="(item, index) in questionList.data">
						<navigator :url="'/pages/article/ask_detail/ask_detail?id=' + item.id" class="quesitem">
							<view class="askbox">
								<view class="flex-box">
									<view class="bao">问</view>
									<view class="fs32 fwb">{{ item.question }}</view>
								</view>
								<view class="pay-date flex-box js">
									<view>
										<text class="col3 pr20">{{ item.user.nickname }}</text>
										<text></text>
									</view>
									<view>{{ item.createtime_text }}</view>
								</view>
							</view>
							<view v-if="item.state == 2" class="ansbox flex">
								<view class="dong">答</view>
								<view class="ansright">
									<view class="ansdetail">{{ item.answer }}</view>
									<view class="flex-box flex-between">
										<view class="flex-box">
											<image :lazy-load="true" :src="item.broker.avatar" class="avatar" mode="aspectFill"></image>
											<text class="col89 fs24 pr20">{{ item.broker.nickname }}</text>
											<text class="col89 fs24">毕业于{{ item.brokerprofile.college }}</text>
										</view>
										<view @tap.stop.prevent="likeAnswer" :data-index="index" class="flex-box">
											<image :src="'/static/icon/icon_zan' + (item.is_like ? '-on' : '') + '.png'" class="icon_zan"></image>
											<text :class="'fs24 col89 ' + (item.is_like ? 'coloractive' : '')">有用({{ item.like_num }})</text>
										</view>
									</view>
								</view>
							</view>
							<block v-else>
								<view class="ansbox flex">未解决</view>
							</block>
						</navigator>
					</block>
					<u-loadmore v-if="questionList.total > 9" :status="loadStatus1" fontSize="24" line loading-text="努力加载中" loadmore-text="轻轻上拉"  nomore-text="没有更多了" />
				</block>
				<block v-else>
					<u-empty
					        mode="data"
							text="暂无数据"
							textSize="24"
					        icon="/static/images/none-data.png"
					>
					</u-empty>
				</block>
			</view>
		</view>

		<view class="part3 pt140" v-if='menu==2'>
			<view class="bigbox">
				<view class="dynamic">
					<image :src="house_trend_image" mode="aspectFill"></image>
					<view class="tips">一手楼盘动态，实时播报</view>
				</view>
			</view>
			<view class="dynamiclist">
				<template v-if="trendsList.total > 0">
					<template v-for="(item, index) in trendsList.data">
						<navigator :url="'/pages/house/building_detail/building_detail?id=' + item.house_id" hover-class="none" class="dynamicitem">
							<view class="flex-box title">
								<view class="col89">{{ item.show_date }}</view>
								<view v-if="item.is_new" class="new">new</view>
							</view>
							<view class="flex-box">
								<view class="houseimg">
									<image :lazy-load="true" :src="item.house.image_text" mode="aspectFill"></image>
								</view>
								<view class="flex-grow-1">
									<view class="flex-box flex-between">
										<view class="fs32">{{ item.house.name }}</view>
										<view class="sale_type1">{{ item.house.sale_state_text }}</view>
									</view>
									<view class="col89 fs26 pt10 pb10">总价：{{ item.house.min_total_price }}-{{ item.house.max_total_price }}万</view>
									<view class="col89 fs26 flex-box flex-between">
										<text>单价：¥{{ item.house.price }}/㎡</text>
										<text class="fs24">{{ item.house.city }} | {{ item.house.region }}</text>
									</view>
								</view>
							</view>
							<view class="newrec">{{ item.name }}</view>
							<view class="size-price">{{ item.content }}</view>
							<view class="flex-box flex-between">
								<button @tap.stop.prevent="addAppointLog" data-type="2" data-subtype="0" :data-house_id="item.house_id" class="flex-box flex-center contact">
									<image src="/static/icon/icon_kefu-b.png" class="icon_kefu-b"></image>
									<view class="fs30 col009">咨询优惠详情</view>
								</button>
								<!-- #ifdef MP -->
								<button open-type="share" class="flex-box share">
									<image src="/static/icon/icon_share-b.png" class="icon_share-b"></image>
									<view class="fs24">分享</view>
								</button>
								<!-- #endif -->
								<!-- #ifdef APP-PLUS -->
								<button @tap.stop.prevent="sharemp" class="flex-box share">
									<image src="/static/icon/icon_share-b.png" class="icon_share-b"></image>
									<view class="fs24">分享</view>
								</button>
								<!-- #endif -->
								<!-- #ifdef H5 -->
								<button @tap.stop.prevent="copyUrl" class="flex-box share">
									<image src="/static/icon/icon_share-b.png" class="icon_share-b"></image>
									<view class="fs24">分享</view>
								</button>
								<!-- #endif -->
							</view>
						</navigator>
					</template>
					<u-loadmore  v-if="trendsList.total > 9" :status="loadStatus2" fontSize="24" line loading-text="努力加载中" loadmore-text="轻轻上拉"  nomore-text="没有更多了" />
				</template>
				<template v-else>
					<u-empty
					        mode="data"
							text="暂无数据"
							textSize="24"
					        icon="/static/images/none-data.png"
					>
					</u-empty>
				</template>
			</view>
		</view>

		<l-painter isCanvasToTempFilePath @success="path = $event" custom-style="position: fixed; left: 200%"  :pixel-ratio="2" path-type="url"
			@progress="progress()" css="width: 600rpx; padding: 40rpx 30rpx; background: #fff;border-radius:12rpx" useCORS>
			<l-painter-view css="position:relative">
				<l-painter-view css="margin-bottom: 20rpx; color: #101010; font-weight: bold; font-size: 34rpx; ">
					<l-painter-text text="分享一篇楼市好文" />
				</l-painter-view>
				<l-painter-view css="padding-bottom:30rpx">
					<l-painter-image :src="info.image_text"
						css="object-fit: cover; object-position: 50% 50%; width: 100%; height: 250rpx; border-radius: 12rpx;" />
				</l-painter-view>
				<l-painter-view css="margin-bottom: 20rpx; color: #101010; font-size: 30rpx;">
					<l-painter-text :text="info.name"
						css="line-clamp: 1;line-height: 1.8em;" />
				</l-painter-view>
				<l-painter-view css="margin-bottom: 20rpx; color: #898989; font-size: 24rpx;">
					<l-painter-text :text="info.description"
						css="line-clamp: 1;line-height: 1.8em;" />
				</l-painter-view>
				<l-painter-view css="padding-bottom:30rpx;font-size:24rpx;color:#898989;position:relative;">
					<l-painter-image :src="info.author_avatar_text"
						css="object-fit: cover; object-position: 50% 50%; width: 55rpx; height: 55rpx; border-radius: 50%;margin-right:20rpx;display:inline-block;" />
					<l-painter-view css="display:inline-block;width:170rpx;line-height:55rpx;">
						<l-painter-text :text="info.author" />
					</l-painter-view>
					<l-painter-view
						css="display:inline-block;line-height:55rpx;text-align:right;position:absolute;right:0;">
						<l-painter-text :text="info.createtime_text" />
					</l-painter-view>
				</l-painter-view>
				<l-painter-view css="width:540rpx;position:relative;">
					<l-painter-view css="font-size:24rpx;">
						<l-painter-image :src="app_logo"
							css="object-fit: cover; object-position: 50% 50%; width: 85rpx; height: 85rpx; border-radius: 50%;margin-bottom:13rpx" />
						<l-painter-text text="佳和房产" css="display:block;" />
					</l-painter-view>
					<l-painter-view
						css="position:absolute;right:90rpx;text-align:right;top:30rpx;font-size:20rpx;color:#898989;">
						<l-painter-text text="长按识别二维码" css="display:block;" />
						<l-painter-text text="阅读全文" css="display:block;" />
					</l-painter-view>
					<l-painter-view css="display:inline-block;position:absolute;right:-60rpx">
						<l-painter-image :src="share_qrcode" css="width: 130rpx; height: 130rpx;" />
					</l-painter-view>
				</l-painter-view>
			</l-painter-view>
		</l-painter>

		<u-popup :show="canvaspop" mode="center" closeable :safeAreaInsetBottom="false" @close="closemask" closeOnClickOverlay
			bgColor="transparent">
			<view class="canvaspop">
				<!-- #ifdef H5 -->
				<img :src="path" mode="widthFix" style="width: 100%;"></img>
				<!-- #endif -->
				<!-- #ifndef H5 -->
				<image :src="path" mode="widthFix" style="width: 100%;"></image>
				<!-- #endif -->
				<!-- #ifndef H5 -->
				<view class="flex-box flex-between btnbox">
					<!-- #ifdef MP -->
					<button open-type="share" class="btn">分享给好友</button>
					<!-- #endif -->
					<!-- #ifndef MP -->
					<button class="btn" @click="sharewx()">分享给好友</button>
					<!-- #endif -->
					<button class="btn" @click="saveImage()">保存分享海报</button>
				</view>
				<!-- #endif -->
				<!-- #ifdef H5 -->
				<view class="flex-box flex-center btnbox">
					<button class="btn">长按图片保存</button>
				</view>
				<!-- #endif -->
			</view>
		</u-popup>
		
		<!-- 预约弹窗start -->
		<u-popup :show="popupStatus" mode="center" round="8" :safeAreaInsetBottom="false" @close="closePopupStatus" closeOnClickOverlay>
			<view class="zixun-pop">
				<view class="fs40 black tc mb20">我要咨询</view>
				<view class="fs30 col-darkGray tc mb40">
					<view>虹桥金茂悦有哪些劣势？性价比如何？</view>
					<view>还有什么类似楼盘推荐……</view>
					<view>更多问题，咨询师帮你答疑解惑</view>
				</view>
				<view class="input-box flex-box plr30 mb40" v-if="popupStatus"><input @input="appoint_mobileFun" :value="appoint_mobile" class="input flex-grow-1" type="number" placeholder="请输入手机号码" placeholder-style="color:#ccc;" /></view>
				<view  @tap="submitAppointLog" class="btn1 mb30">确认</view>
				<!-- <view @tap="jumpToChat" :data-uid="broker_user_id" class="btn2 mb20">立即微聊</view> -->
				<button open-type="contact" class="btn2 mb20">立即微聊</button>
			</view>
		</u-popup>
		<!-- 预约弹窗end -->
		<!-- 预约成功弹窗start -->
		<u-popup :show="reserveStatus" mode="center" closeable :safeAreaInsetBottom="false" @close="closeReserveStatus" closeOnClickOverlay>
			<view class="reserve">
				<image src="/static/icon/icon_reserve.png" class="icon_reserve"></image>
				<view class="title1">预约成功</view>
				<view class="title2">用手机号码{{ appoint_mobile_text }}预约了咨询服务，稍后经纪人将为您解答疑问，请注意接听电话</view>
				<button @tap="closeReserveStatus" class="reserve-btn1">好的</button>
				<!-- <button @tap="jumpToChat" :data-uid="broker_user_id" class="reserve-btn2">立即微聊</button> -->
				<button open-type="contact" class="reserve-btn2">立即微聊</button>
			</view>
		</u-popup>
		<!-- 预约成功弹窗end -->
		
	</view>
</template>

<script>
	const app = getApp();
	
	const functions = require('../../../utils/functions.js');
	export default {
		data() {
			return {
				loadStatus0:'loadmore',
				loadStatus1:'loadmore',
				loadStatus2:'loadmore',
				
				path: '',
				
				is_ajax_list:false,
				btnStatus:false,//提交数据拦截重复提交
				
				popupStatus: false,//预约弹窗
				//订阅咨询预约弹窗
				reserveStatus: false,
				// 预约订阅类型，分类:1=订阅动态,2=留电咨询,3=领取免费专车,4=帮你找房,5=咨询房价走势
				appoint_type: 1,
				// 订阅分类，订阅通知类型:0=无订阅,1=订阅变价通知,2=订阅开盘通知,3=订阅实时动态
				appoint_subscribe_type: 0,
				// 预约手机号
				appoint_mobile: '',
				appoint_mobile_text: '',
				broker_user_id: 0,
				
				menu: 0, //顶部菜单
				app_logo: '',
				share_qrcode: '',
				author_avatar: '',
				article_image: '',
				info: {},
				canvaspop: false,
				filePaths: '',
				is_ask: false,
				// 文章列表
				articleList: {
					total: 0,
					current_page: 0,
					last_page: 1,
					data: []
				},
				articleType: [],
				//文章分类
				article_category_id: 0,
				sort: 1,
				//排序:0=排序字段从大到小，1=创建时间从大到小，2=按热度从大到小
				keyword: '',
				is_has_image: 1,
				//是否有图：1=全部，2=有
				tags_id: 0,
				// 买房问问分类
				questionType: [],
				// 买房问问列表
				questionList: {
					total: 0,
					current_page: 0,
					last_page: 1,
					data: []
				},
				// 楼盘动态列表
				trendsList: {
					current_page: 0,
					last_page: 1,
					data: [],
					total: 0
				},
				now_city: '上海市',
				advertData: [],
				//广告图
				house_trend_image: '',
				
				onOff:false,//显示隐藏
			}
		},
		onLoad: function (options) {
			this.now_city = uni.getStorageSync('now_city')||'上海市';
			this.initData();
		},
		onShow: function () {
			// 开关 1关 2开
			this.onOffFun();
			if (app.globalData.is_need_page_change) {
				var param = app.globalData.pagesParam;
				app.globalData.is_need_page_change = false;
	
				if (param.nav) {
					this.menu= Number(param.nav) - 1
					this.initData();
				}
			}
	
			var now_city = uni.getStorageSync('now_city') || '上海市';
	
			if (now_city != this.now_city) {
				this.now_city=now_city
	
				if (this.menu == 2) {
					this.trendsList.current_page=0
					that.getloadingList();
				}
			}
			this.house_trend_image= app.globalData.config.house_trend_image;
			app.setMessageBadge(false)
		},
		onPullDownRefresh: function () {
			uni.showNavigationBarLoading(); //在标题栏中显示加载
	
			var that = this; 
			setTimeout(function () {
				that.initData();
				uni.stopPullDownRefresh(); //停止下拉刷新
			}, 1500);
		},
		onReachBottom: function () {
			var listdata=(this.menu == 0)?this.articleList:((this.menu == 1)?this.questionList:this.trendsList);
			if (listdata.current_page >= listdata.last_page) {
				this.changeloadStatus('nomore');
				return false;
			} 
			this.getloadingList();
		},
		onShareAppMessage: function (res) {
			if (res.from == 'button') {
				if (this.menu == 0) {
					return {
						title: this.info.name,
						imageUrl: this.path,
						path: '/pages/article/info_detail/info_detail?id=' + this.info.id
					};
				} else {
					functions.dotask(this, 5);
					return { 
						title: '佳和房产',
						path: '/pages/home/index/index'
					};
				}
			}
		},
		methods: {
			onOffFun(){
				var that = this;
				
				var json = {
					
				};
				functions.getAjaxData('/api/xiluhouse/house/qa_switch', json, function (res) {
					that.onOff=(res.data.type==2)?true:false;//1关 2开
					console.log('1关 2开:'+res.data.type)
					console.log(that.onOff)
				}); 
			},
			sharemp(){
				uni.share({
				    provider: 'weixin',
				    scene: "WXSceneSession",
				    type: 5,
				    imageUrl: app.globalData.config.app_logo,
				    title: '佳和房产',
				    miniProgram: {
				        id: 'gh_632f774183ba',
				        path: '/pages/home/index/index',
				        type: 0,
				        webUrl: app.globalData.web_url
				    },
				    success: ret => {
				        console.log(JSON.stringify(ret));
				    }
				});
			},
			copyUrl() {
			    var url = app.globalData.h5_url+'/pages/home/index/index';
			    uni.showModal({
			    	content: '确定复制分享链接？',
			    	confirmText: '确定',
					success: () => {
						uni.setClipboardData({
							data: url,
							success: function() {
								uni.hideToast({
									title: '复制成功',
									duration: 2000,
									icon: 'none'
								});
							},
							fail: function(err) {
								uni.showToast({
									title: '复制失败',
									duration: 2000,
									icon: 'none'
								});
							}
						});
					}
				});
			},
			sharewx(){
				uni.share({
					provider: "weixin",
					scene: "WXSceneSession",
					type: 2,
					imageUrl: this.path,
					success: function (res) {
						console.log("success:" + JSON.stringify(res));
					},
					fail: function (err) {
						console.log("fail:" + JSON.stringify(err));
					}
				});
			},
			saveImage() {
				functions.saveImages(this.path);
			},
			share(e) {
				if (!uni.getStorageSync('token')){
					functions.toast('请先登录')
					return;
				}
				let that = this;
				var index = e.currentTarget.dataset.index;
				var info = this.articleList.data[index];
				var id = info.id;
				this.info=info;
				this.app_logo = app.globalData.config.app_logo; // 获取---搜索数据
	
				functions.getAjaxData(
					'/api/xiluhouse/article/share_qrcode',
					{
						id: id
					},
					function (res) {
						that.share_qrcode=res.data
					}
				);
				that.canvaspop = true;
			},
			progress(e) {
				if (e > 0) {
					uni.hideLoading();
				}
			},
			closemask() {
				this.canvaspop = false;
			},
			
			// 广告的跳转
			jumpAdvertTo(event) {
				var that = this;
				var param = event.currentTarget.dataset.param; 
			
				if (param.goto_type == 1) {
					return false;
				} 
				// $goto_type  - 跳转方式:1=不跳转,2=跳转外链,3=跳转内链,4=我要订阅
			
				if (param.goto_type == 4) {
					// 我要订阅
					// 处理手机号码
					var appoint_mobile = uni.getStorageSync('mobile') || that.appoint_mobile;
					this.broker_user_id=0;
					this.appoint_mobile=appoint_mobile;
					this.popupStatus=false;
					this.appoint_type=1;
					this.appoint_subscribe_type=3;
					that.submitAppointLog();
				} else if (param.goto_type == 2) {
					uni.navigateTo({
						url: '/pages/webview/webview?url=' + param.goto_url
					});
				} else if (param.goto_type == 5) {
					uni.navigateTo({
						url: '/pages/webview/webview?url=' + param.goto_url
					});
				} else if (param.goto_type == 3) {
					var redirectArr = ['/pages/index/index', '/pages/building_list/building_list', '/pages/information/information', '/pages/personal/personal'];
			
					if (param.insidepages.is_need_login == 2) {
						app.globalData.nowThat = that;
						functions.checkLogin(function (ret) {
							if (ret) {
								if (redirectArr.indexOf(param.insidepages.wxmini_url) == -1) {
									if (param.insidepages.is_need_param == 2) {
										uni.navigateTo({
											url: param.insidepages.wxmini_url + '?id=' + param.goto_param
										});
									} else {
										uni.navigateTo({
											url: param.insidepages.wxmini_url
										});
									}
								} else {
									uni.switchTab({
										url: param.insidepages.wxmini_url
									});
								}
							} else {
								functions.toast('请先登录');
							}
						});
					} else {
						if (redirectArr.indexOf(param.insidepages.wxmini_url) == -1) {
							if (param.insidepages.is_need_param == 2) {
								uni.navigateTo({
									url: param.insidepages.wxmini_url + '?id=' + param.goto_param
								});
							} else {
								uni.navigateTo({
									url: param.insidepages.wxmini_url
								});
							}
						} else {
							uni.switchTab({
								url: param.insidepages.wxmini_url
							});
						}
					}
				}
			},
			jumpToChat(e) {
				var uid = e.currentTarget.dataset.uid || 0;
				var that = this;
				functions.checkLogin(function (ret) {
					if (ret) {
						functions.jumpToChat(uid);
					} else {
						functions.toast('请先登录');
					}
				});
			},
			// 添加预约记录
			addAppointLog(e) {
				this.appoint_type= e.currentTarget.dataset.type;
				this.appoint_subscribe_type= e.currentTarget.dataset.subtype;
				this.broker_user_id= e.currentTarget.dataset.uid || 0; 
				// 处理手机号码
				this.appoint_mobile= uni.getStorageSync('mobile') || this.appoint_mobile;
				this.popupStatus=true;
			},
			
			appoint_mobileFun(e) {
				this.appoint_mobile=e.detail.value
			},
			// 提交预约日志
			submitAppointLog() {
				var that = this;
				if (that.appoint_mobile.length != 11) {
				  functions.toast('请输入正确的手机号');
				  return false;
				}
				functions.checkLogin(function (ret) {
					if (ret) {
						var appoint_mobile = uni.getStorageSync('mobile');
						that.appoint_mobile=appoint_mobile;
			
						functions.submitAjaxData(
							that,
							'/api/xiluhouse/house/create_appoint_log',
							{
								type: that.appoint_type,
								subscribe_type: that.appoint_subscribe_type,
								mobile: that.appoint_mobile,
								broker_user_id: that.broker_user_id,
								city: that.now_city,
								orther_areas: that.orther_areas,
								house_search_roomnum_ids: that.house_search_roomnum_ids,
								min_total_price: that.min_total_price,
								max_total_price: that.max_total_price
							},
							function (res) {
								that.appoint_mobile = that.appoint_mobile;
								that.appoint_mobile_text = appoint_mobile.substr(0, 3) + '****' + appoint_mobile.substr(7);
								that.reserveStatus=true;
								that.popupStatus=false;
							}
						);
					} else {
						functions.toast('请先登录');
					}
				});
			},
			closePopupStatus() {
				this.popupStatus=false;
			},
			closeReserveStatus() {
				this.reserveStatus=false;
			},
			
			// 点赞回复答案
			likeAnswer(e) {
				var index = e.currentTarget.dataset.index;
				var data = this.questionList.data;
				var now_info = data[index];
	
				if (now_info.is_like) {
					return false;
				}
	
				var that = this;
				functions.checkLogin(function (ret) {
					if (ret) {
						//继续提交
						functions.submitAjaxData(
							that,
							'/api/xiluhouse/Question/like_answer',
							{
								id: now_info.id
							},
							function (res) {
								data[index].is_like = true;
								data[index].like_num = 1 + Number(now_info.like_num);
								that.questionList.data=data
							}
						);
					} else {
						functions.toast('请先登录');
					}
				});
			},
	
			// 切换问题分类
			changequestionType(e) {
				var is_has_image = e.currentTarget.dataset.has || 0;
				var tags_id = e.currentTarget.dataset.id || 0;
				this.is_has_image=is_has_image
				this.tags_id=tags_id
				this.questionList.current_page=0
				this.menu=1
				this.getloadingList();
			},
	
			// 搜索买房问问
			doSearch(e) {
				this.keyword= e.detail.value
				this.questionList.current_page=0
				this.getloadingList();
			},
	
			// 切换买房问问搜索状态
			changeQuestionSearch() {
				this.is_ask=!this.is_ask
			},
	
			// 切换文章分类
			changearticleType(e) {
				this.sort = e.currentTarget.dataset.sort || 0;
				this.article_category_id = e.currentTarget.dataset.id || 0;
				this.menu=0
				this.articleList.current_page=0
				this.getloadingList();
			},
	
			// 广告的跳转
			jumpAdvertTo1(event) {
				var that = this;
				var param = event.currentTarget.dataset.param; 
			
				if (param.goto_type == 1) {
					return false;
				} 
				// $goto_type  - 跳转方式:1=不跳转,2=跳转外链,3=跳转内链,4=我要订阅
			
				if (param.goto_type == 4) {
					// 我要订阅
					// 处理手机号码
					var appoint_mobile = uni.getStorageSync('mobile') || that.appoint_mobile;
					this.broker_user_id=0;
					this.appoint_mobile=appoint_mobile;
					this.popupStatus=false;
					this.appoint_type=1;
					this.appoint_subscribe_type=3;
					that.submitAppointLog();
				} else if (param.goto_type == 2) {
					uni.navigateTo({
						url: '/pages/webview/webview?url=' + param.goto_url
					});
				} else if (param.goto_type == 5) {
					uni.navigateTo({
						url: '/pages/webview/webview?url=' + param.goto_url
					});
				} else if (param.goto_type == 3) {
					var redirectArr = ['/pages/index/index', '/pages/building_list/building_list', '/pages/information/information', '/pages/personal/personal'];
			
					if (param.insidepages.is_need_login == 2) {
						app.globalData.nowThat = that;
						functions.checkLogin(function (ret) {
							if (ret) {
								if (redirectArr.indexOf(param.insidepages.wxmini_url) == -1) {
									if (param.insidepages.is_need_param == 2) {
										uni.navigateTo({
											url: param.insidepages.wxmini_url + '?id=' + param.goto_param
										});
									} else {
										uni.navigateTo({
											url: param.insidepages.wxmini_url
										});
									}
								} else {
									uni.switchTab({
										url: param.insidepages.wxmini_url
									});
								}
							} else {
								functions.toast('请先登录');
							}
						});
					} else {
						if (redirectArr.indexOf(param.insidepages.wxmini_url) == -1) {
							if (param.insidepages.is_need_param == 2) {
								uni.navigateTo({
									url: param.insidepages.wxmini_url + '?id=' + param.goto_param
								});
							} else {
								uni.navigateTo({
									url: param.insidepages.wxmini_url
								});
							}
						} else {
							uni.switchTab({
								url: param.insidepages.wxmini_url
							});
						}
					}
				}
			},
			
			// 切换顶部菜单
			choosemenu(e) {
				let index = e.currentTarget.dataset.menuindex;
				this.menu=index
	
				if (this.menu == 0) {
					this.articleList.current_page=0
				} else if (this.menu == 1) {
					this.questionList.current_page=0
				} else {
					this.trendsList.current_page= 0
				}
	
				this.getloadingList();
			},
			changeloadStatus(status){
				if(this.menu==0){
					this.loadStatus0=status;
				}else if(this.menu==1){
					this.loadStatus1=status;
				}else if(this.menu==2){
					this.loadStatus2=status;
				}
			},
			// 获取列表信息
			getloadingList: function () {
				var that = this;
	
				if (this.menu == 0) {
					var loadingList = this.articleList;
					var json = {
						classify: 3,
						article_category_id: that.article_category_id,
						sort: that.sort
					};
					var url = '/api/xiluhouse/article/article_list';
				} else if (this.menu == 1) {
					var loadingList = this.questionList;
					var json = {
						keyword: that.keyword,
						is_has_image: that.is_has_image,
						//是否有图：1=全部，2=有
						tags_id: that.tags_id
					};
					var url = '/api/xiluhouse/Question/questions_list';
				} else {
					var loadingList = this.trendsList;
					var json = {
						city: that.now_city
					};
					var url = '/api/xiluhouse/Housetrends/house_trends_list';
				}
	
				json.page = Number(loadingList.current_page) + 1;
	
				if (json.page > 1 && loadingList.current_page >= loadingList.last_page) {
					functions.toast('已加载到底部了');
					this.changeloadStatus('nomore');
					return false;
				}
				this.changeloadStatus('loading');
				
				functions.getAjaxList(that, url, json, function (res) {
					var loadingList = res.data;
	
					if (json.page > 1) {
						var now_loadingList_data = loadingList.data || [];
						var now_loadingList_data = now_loadingList_data.concat(loadingList.data);
						loadingList.data = now_loadingList_data;
					}
					
					if(loadingList.current_page >= loadingList.last_page){
						that.changeloadStatus('nomore');
					}
					if (that.menu == 0) {
						that.articleList=loadingList
					} else if (that.menu == 1) {
						that.questionList=loadingList
					} else {
						that.trendsList=loadingList
					}
				});
			},
	
			// 获取所有可下拉刷新更新的数据
			initData: function () {
				var that = this;
	
				var json = {
					position: 5,
					position_type: 1
				};
				functions.getAjaxData('/api/xiluhouse/universal/advert_data', json, function (res) {
					that.advertData=res.data
				}); 
				var json = {
					classify: 3
				};
				functions.getAjaxData('/api/xiluhouse/article/article_category_data', json, function (res) {
					that.articleType= res.data
				});
				functions.getAjaxData('/api/xiluhouse/question/question_tags_data', {}, function (res) {
					that.questionType=res.data
				});
	
				if (this.menu == 0) {
					this.articleList.current_page= 0
				} else if (this.menu == 1) {
					this.questionList.current_page=0
				} else {
					this.trendsList.current_page=0
				}
	
				if (!app.globalData.is_need_page_change) {
					that.getloadingList();
				}
			},
			
		}
	}
</script>

<style lang="scss">
	.coloractive {
	    color: #0091ff;
	}
	.zixun-pop {
		position: relative;
		padding: 90rpx 40rpx 40rpx;
		width: 600rpx;
		max-height: 900rpx;
		background: #ffffff;
		overflow-y: scroll;
		border-radius: 8rpx;
	}
	.zixun-pop .input-box {
		width: 100%;
		height: 90rpx;
		background: #f6f7fa;
		border-radius: 10rpx;
	}
	.zixun-pop .input {
		font-size: 30rpx;
		color: #333;
		line-height: 42rpx;
	}
	.zixun-pop .btn1 {
		width: 100%;
		height: 90rpx;
		background: #0091ff;
		box-shadow: 0 4rpx 40rpx 0 rgba(3, 103, 179, 0.3);
		border-radius: 10rpx;
		font-size: 30rpx;
		color: #ffffff;
		line-height: 90rpx;
		text-align: center;
	}
	.zixun-pop .btn2 {
		width: 100%;
		height: 90rpx;
		background: #ff7b40;
		box-shadow: 0 4rpx 40rpx 0 rgba(248, 103, 56, 0.3);
		border-radius: 10rpx;
		font-size: 30rpx;
		color: #ffffff;
		line-height: 90rpx;
		text-align: center;
	}
	
	.container {
		background-color: #f6f7fa;
	}

	.pt140 {
		padding-top: 140rpx;
	}


	.menu {
		padding: 0 40rpx;
		height: 114rpx;
		border-bottom: 1px solid #f4f3f3;
		background-color: var(--white);
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
		z-index: 10;
		background-color: var(--white);
	}

	/* #ifdef H5 */
	.menu {
		top: calc(var(--status-bar-height) + 44px);
	}

	/* #endif */
	.menu .menuitem {
		flex: 1;
		text-align: center;
		line-height: 114rpx;
		position: relative;
		font-size: var(--fs34);
	}

	.menu .menuitem.active {
		color: var(--blue);
	}

	.menu .menuitem.active::after {
		content: "";
		display: block;
		width: 30rpx;
		height: 6rpx;
		border-radius: 50rpx;
		background-color: var(--blue);
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		bottom: 20rpx;
	}

	.part1 {
		background-color: var(--white);
	}

	.part1 .swiper {
		width: 670rpx;
		height: 240rpx;
		border-radius: 10rpx;
		margin: 0 auto 28rpx;
	}

	.part1 .swiper image {
		width: 670rpx;
		height: 240rpx;
	}

	.points {
		white-space: nowrap;
		line-height: 82rpx;
		height: 82rpx;
		border-top: 1px solid #f4f3f3;
		border-bottom: 1px solid #f4f3f3;
		overflow-x: scroll;
		overflow-y: hidden;
		background-color: var(--white);
	}

	.points .point {
		display: inline-block;
		padding: 0 40rpx;
		height: 82rpx;
	}

	.points .point.active {
		color: var(--blue);
	}

	.informationlist {
		padding: 0 40rpx;
	}

	.informationlist .infoitem {
		padding: 30rpx 0;
		border-bottom: 1px solid #f4f3f3;
	}

	.informationlist .infoitem:last-child {
		border-bottom: transparent;
	}

	.informationlist .infoitem .infopic {
		width: 200rpx;
		height: 150rpx;
		border-radius: 10rpx;
		margin-left: 32rpx;
		overflow: hidden;
	}

	.informationlist .infoitem .title {
		font-size: var(--fs32);
		line-height: 43rpx;
		margin-bottom: 30rpx;
	}

	.informationlist .infoitem .detail {
		font-size: var(--fs24);
		color: #898989;
	}

	.informationlist .infoitem .avatar {
		width: 55rpx;
		height: 55rpx;
		border-radius: 50%;
		margin-right: 20rpx;
	}

	.informationlist .infoitem .avatar-share {
		padding-top: 38rpx;
	}

	.informationlist .infoitem .share {
		padding: 0;
		height: 55rpx;
		margin: 0;
		font-weight: normal;
		color: #898989;
		width: auto;
		font-size: var(--fs24);
	}

	.informationlist .infoitem .icon_share-b {
		width: 40rpx;
		height: 40rpx;
		margin-right: 10rpx;
	}

	.part2 .icon_ask {
		width: 605rpx;
		height: 195rpx;
		display: block;
		margin: 0 auto 10rpx;
	}

	.part2 .askbtn {
		padding: 0;
		margin: 0;
		flex: 1;
		height: 110rpx;
		font-weight: normal;
	}

	.part2 .askbtn image {
		width: 50rpx;
		height: 50rpx;
		margin-right: 15rpx;
	}


	.queslist {
		padding: 30rpx 30rpx 0;
	}

	.queslist .quesitem {
		padding: 30rpx;
		border-radius: 10rpx;
		background-color: var(--white);
		margin-bottom: 30rpx;
	}

	.queslist .quesitem .bao {
		width: 40rpx;
		text-align: center;
		line-height: 40rpx;
		font-size: var(--fs24);
		height: 40rpx;
		border-radius: 10rpx;
		background: linear-gradient(180deg, #00C4FF, #0091FF);
		color: var(--white);
		margin-right: 10rpx;
	}

	.queslist .quesitem .dong {
		width: 40rpx;
		text-align: center;
		line-height: 40rpx;
		font-size: var(--fs24);
		height: 40rpx;
		border-radius: 10rpx;
		background: linear-gradient(270deg, #FF6635, #FFB45C);
		color: var(--white);
		margin-right: 10rpx;
	}

	.queslist .pay-date {
		padding-left: 50rpx;
		color: #898989;
		padding-top: 12rpx;
		padding-bottom: 20rpx;
	}

	.queslist .pay-date view,
	.queslist .pay-date text {
		font-size: var(--fs24);
	}

	.queslist .ansright {
		flex: 1;
		padding: 23rpx 30rpx 21rpx;
		border-radius: 10rpx;
		background: #f6f7fa;
	}

	.queslist .ansright .avatar {
		width: 55rpx;
		height: 55rpx;
		border-radius: 50%;
		margin-right: 10rpx;
	}

	.queslist .ansright .ansdetail {
		color: #333333;
		line-height: 39rpx;
		padding-bottom: 23rpx;
	}

	.queslist .icon_zan {
		width: 30rpx;
		height: 30rpx;
		margin-top: -4rpx;
		margin-right: 15rpx;
	}


	.part3 {
		background-color: var(--white);
	}

	.part3 .bigbox {
		padding-bottom: 40rpx;
		border-bottom: 1px solid #f4f3f3;
	}

	.dynamic {
		margin: 0 40rpx;
		width: 670rpx;
		height: 240rpx;
		border-radius: 10rpx;
		overflow: hidden;
		position: relative;
	}

	.dynamic image {
		width: 670rpx;
		height: 240rpx;
	}

	.dynamic .tips {
		width: 670rpx;
		height: 240rpx;
		position: absolute;
		top: 0;
		left: 0;
		line-height: 240rpx;
		text-align: center;
		font-size: 50rpx;
		color: var(--white);
		background: rgba(0, 0, 0, .6);
	}


	.dynamiclist {
		padding: 0 40rpx 40rpx;
	}

	.dynamicitem {
		position: relative;
		padding: 36rpx 0 4rpx 30rpx;
	}

	.dynamicitem::after {
		content: '';
		display: block;
		height: 100%;
		width: 2rpx;
		background: #f4f3f3;
		position: absolute;
		left: 0;
		top: 10%;
		z-index: 1;
	}

	.dynamicitem::before {
		content: '';
		display: block;
		width: 18rpx;
		height: 18rpx;
		background: linear-gradient(180deg, #00C4FF, #0091FF);
		position: absolute;
		left: -8rpx;
		top: 9%;
		border-radius: 50%;
		z-index: 2;
	}

	.dynamicitem .new {
		background: linear-gradient(270deg, #FFB45C, #FF6635);
		width: 60rpx;
		height: 34rpx;
		border-radius: 10rpx 0 10rpx 0;
		line-height: 34rpx;
		text-align: center;
		font-size: var(--fs24);
		color: var(--white);
		margin-left: 35rpx;
	}

	.dynamicitem .houseimg {
		width: 164rpx;
		height: 130rpx;
		border-radius: 10rpx;
		overflow: hidden;
		margin-right: 32rpx;
	}

	.dynamicitem .houseimg image {
		width: 164rpx;
		height: 130rpx;
	}

	.dynamicitem .title {
		padding-bottom: 43rpx;
	}

	.dynamicitem .newrec {
		font-size: var(--fs32);
		color: var(--blue);
		padding: 40rpx 0 22rpx;
	}

	.dynamicitem .size-price {
		padding-bottom: 30rpx;
	}

	.icon_kefu-b {
		width: 32rpx;
		height: 35rpx;
		margin-right: 16rpx;
	}

	.dynamicitem .contact {
		width: 480rpx;
		height: 80rpx;
		border: 2rpx solid var(--blue);
		border-radius: 10rpx;
		margin: 0;
		padding: 0;
	}

	.dynamicitem .share {
		padding: 0;
		height: 55rpx;
		margin: 0;
		font-weight: normal;
		color: #898989;
		width: auto;
		font-size: var(--fs24);
	}

	.dynamicitem .icon_share-b {
		width: 40rpx;
		height: 40rpx;
		margin-right: 10rpx;
	}


	.canvaspop {
		width: 600rpx;
	}

	.canvaspop .canvas {
		width: 600rpx;
		height: 863rpx;
		position: absolute;
		top: -9999px;
		right: -9999px;
	}

	.canvaspop .post {
		width: 600rpx;
		height: 863rpx;
		border-radius: 8rpx;
	}

	.canvaspop .btn {
		width: 250rpx;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		color: var(--white);
		font-size: var(--fs30);
		text-align: center;
		font-weight: normal;
		border-radius: 8rpx;
		border: 1px solid var(--white);
		background: transparent;
		padding: 0;
		margin: 0;
	}

	.canvaspop .btnbox {
		padding: 40rpx 30rpx 0;
	}

	.icon-close {
		position: absolute;
		right: 30rpx;
		top: 20rpx;
		z-index: 3;
		width: 50rpx;
		height: 50rpx;
	}

	.search {
		padding: 30rpx 0;
		background-color: var(--white);
	}

	.search-box {
		width: 575rpx;
		height: 50rpx;
		background: #0091FF;
		border-radius: 25rpx;
		margin-left: 40rpx;
	}

	.icon_search {
		width: 24rpx;
		height: 24rpx;
		margin: 0 10rpx 0 23rpx;
	}

	.search .cancel {
		padding: 0 40rpx;
		height: 50rpx;
		color: #898989;
		background-color: var(--white);
		line-height: 50rpx;
	}
</style>
